﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class ProveedoresFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As ProveedoresBE
        Dim tmpProveedores As ProveedoresBE = New ProveedoresBE()
        Try
            With tmpProveedores
                .IdPro = convertDTFromDb.convertInt32(dr.Item("IdPro"))
                .CvePro = convertDTFromDb.ConvertString(dr.Item("CvePro"))
                .RfcPro = convertDTFromDb.ConvertString(dr.Item("RfcPro"))
                .RazonSocial = convertDTFromDb.ConvertString(dr.Item("RazonSocial"))
                .Calle = convertDTFromDb.ConvertString(dr.Item("Calle"))
                .NoExterior = convertDTFromDb.ConvertString(dr.Item("NoExterior"))
                .NoInterior = convertDTFromDb.ConvertString(dr.Item("NoInterior"))
                .Colonia = convertDTFromDb.ConvertString(dr.Item("Colonia"))
                .Localidad = convertDTFromDb.ConvertString(dr.Item("Localidad"))
                .Referencia = convertDTFromDb.ConvertString(dr.Item("Referencia"))
                .Municipio = convertDTFromDb.ConvertString(dr.Item("Municipio"))
                .Estado = convertDTFromDb.ConvertString(dr.Item("Estado"))
                .Pais = convertDTFromDb.ConvertString(dr.Item("Pais"))
                .CodigoPostal = convertDTFromDb.ConvertString(dr.Item("CodigoPostal"))
                .Telefono1 = convertDTFromDb.ConvertString(dr.Item("Telefono1"))
                .Telefono2 = convertDTFromDb.ConvertString(dr.Item("Telefono2"))
                .Fax = convertDTFromDb.ConvertString(dr.Item("Fax"))
                .CorreoElect = convertDTFromDb.ConvertString(dr.Item("CorreoElect"))
                .DirInternet = convertDTFromDb.ConvertString(dr.Item("DirInternet"))
                .Contacto = convertDTFromDb.ConvertString(dr.Item("Contacto"))
                .Zona = convertDTFromDb.ConvertString(dr.Item("Zona"))
                .Grupo = convertDTFromDb.ConvertString(dr.Item("Grupo"))

                Select Case convertDTFromDb.ConvertString(dr.Item("Status"))
                    Case "A"
                        .Status = ProveedoresBE.EstatusProveedor.Activo
                    Case "I"
                        .Status = ProveedoresBE.EstatusProveedor.Inactivo
                    Case Else
                        .Status = ProveedoresBE.EstatusProveedor.Inactivo
                End Select
            End With
            Return tmpProveedores
        Catch ex As Exception
            Throw
        Finally
            tmpProveedores = Nothing
        End Try
    End Function
End Class
